package com.benjaminwan.read.free.model.moshiadapter

import com.squareup.moshi.*

object LongRangeAdapter {
    @FromJson
    fun fromJson(rangeStr: String): LongRange {
        val ret = rangeStr.split("..")
        val start = ret[0].toLong()
        val end = ret[1].toLong()
        return (start..end)
    }

    @ToJson
    fun toJson(range: LongRange): String {
        val start = range.first
        val end = range.last
        return "$start..$end"
    }
}